package com.user.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

import java.util.Map;

public class LoginInterceptor extends MethodFilterInterceptor{
    private Map<String,Object> session = null;
    protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
        session = ActionContext.getContext().getSession();
        Object user = session.get("User");
        if(user!=null){
            return actionInvocation.invoke();
        }else{
            return "login";
        }
    }
}
